from machine import Pin
import utime


if __name__ == "__main__":
    # 创建蜂鸣器对象
    beep = Pin(16, Pin.OUT, value=0)
    # 创建继电器对象
    relay = Pin(17, Pin.OUT, value=0)
    
    # 继电器开关3次
    for _ in range(6):
        relay.value(not relay.value())
        utime.sleep(1)
        
    # 蜂鸣器发声1秒
    beep_val = 0;
    start_ticks, end_ticks = [utime.ticks_ms()] * 2
    while end_ticks - start_ticks <= 1000:
        beep_val = not beep_val
        beep.value(beep_val)
        utime.sleep_us(250) # 2KHz
        end_ticks = utime.ticks_ms()
        
        
    
    
    